//
//  TYSearchControllerAppearance.m
//  TYUIKit
//
//  Created by TuyaInc on 2019/2/11.
//

#import "TYSearchControllerAppearance.h"

#import "TYUIKit.h"
//#import "TYTheme.h" 
@implementation TYSearchControllerAppearance

+ (instancetype)appearance {
    static TYSearchControllerAppearance *instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [TYSearchControllerAppearance new];
    });
    return instance;
}

- (instancetype)init {
    if (self = [super init]) {
//        _searchTableBackgroundColor = [TYTheme theme].app_bg_color;
    }
    return self;
}

- (TYSearchBarAppearance *)searchBarAppearance {
    if (!_searchBarAppearance) {
        _searchBarAppearance = [TYSearchBarAppearance new];
        if (@available(iOS 11.0, *)) {
            self.searchBarBoundsInsets = UIEdgeInsetsMake(12, 0, 0, 0);
            _searchBarAppearance.searchFieldInsets = UIEdgeInsetsMake(10, 2, -2, 2);
            _searchBarAppearance.cancelButtonInsets = UIEdgeInsetsMake(6, -2, -6, 2);
        } else {
            _searchBarAppearance.searchFieldInsets = UIEdgeInsetsMake(0, 2, 0, 2);
            _searchBarAppearance.cancelButtonInsets = UIEdgeInsetsMake(0, -2, 0, 2);
        }
        
        _searchBarAppearance.separatorHeight = 0.5;
//        _searchBarAppearance.separatorColor = TYTheme.theme.app_bg_color.N7;
        
        _searchBarAppearance.searchFieldCorner = 14;
        _searchBarAppearance.searchTextFont = [UIFont systemFontOfSize:14];
//        _searchBarAppearance.searchTextColor = TYTheme.theme.app_bg_color.N1;
        _searchBarAppearance.searchFieldBackgroundColor =
//        TYTheme.theme.app_bg_color.ty_isDarkcolor.boolValue
//        ? [UIColor ty_colorWithHexString:@"#232323"] :
        [UIColor ty_colorWithHexString:@"#f8f8f8"];
        
        _searchBarAppearance.cancelButtonFont = [UIFont systemFontOfSize:16];
//        UIColor *color = TYTheme.theme.app_bg_color.N1;
//        _searchBarAppearance.cancelButtonNormalColor = color;
//        _searchBarAppearance.cancelButtonDisableColor = [color colorWithAlphaComponent:0.4];
    }
    
    return _searchBarAppearance;
}

@end
